
module.exports = app => {

  const apiV1Router = app.router.namespace('/api/v1');
  const apiCmsRouter = app.router.namespace('/api/cms');

  const { controller, middleware } = app;

  const {
    order, user, topic, collect, expert, file, notice, patient, feedback
  } = controller.api;

  const {
    cms,
  } = controller;

  const tokenRequired = middleware.tokenRequired();
  const adminRequired = middleware.adminRequired();

  apiV1Router.get('/patient/list.json', tokenRequired, patient.getPatientList);
  apiV1Router.get('/patient/detail.json', tokenRequired, patient.getPatientDetail);
  apiV1Router.post('/patient/remove.json', tokenRequired, patient.remove);
  apiV1Router.post('/patient/create.json', tokenRequired, patient.create);

  apiV1Router.get('/notice/list.json', notice.getNoticeList);
  apiV1Router.get('/notice/detail.json', notice.getNoticeDetail);
  apiV1Router.post('/notice/create.json', adminRequired, notice.create);

  apiV1Router.post('/file/upload.json', file.uploadFile);

  apiV1Router.post('/user/create.json', user.create);
  apiV1Router.post('/user/login.json', user.login);
  apiV1Router.post('/user/beike/login.json', user.beikeLogin);
  apiV1Router.post('/user/checksession.json', user.checksession);
  apiV1Router.post('/user/userinfo.json', tokenRequired, user.postUserInfo);
  apiV1Router.get('/user/userinfo.json', tokenRequired, user.getUserInfo);


  apiV1Router.post('/feedback/create.json', tokenRequired, feedback.create);


  // 主题
  apiV1Router.post('/topic/create', topic.create);
  apiV1Router.get('/topic/toplist.json', topic.getTopList);
  apiV1Router.get('/topic/list.json', topic.getList);

  apiCmsRouter.get('/getCategorieList.json', cms.getCategorieList);
  apiCmsRouter.get('/topic/list.json', topic.getTopicList);

  
  apiCmsRouter.get('/topic/categorie/list.json', collect.getCategorieList);
  apiCmsRouter.get('/topic/toplist.json', cms.getTopList);
  apiCmsRouter.get('/topic/detail.json', cms.getTopDetail);

  apiV1Router.post('/collect/create', collect.create);
  apiV1Router.get('/collect/list.json', collect.getCollectList);

  
  apiV1Router.post('/expert/evaluate/create.json', tokenRequired, expert.createEvaluation);
  apiV1Router.post('/expert/createEvaluation.json', tokenRequired, expert.createEvaluation);
  apiV1Router.post('/expert/create.json', expert.create);

  apiV1Router.post('/expert/postFollow.json', tokenRequired, expert.postFollow);
  apiV1Router.post('/expert/cancelFollow.json', tokenRequired, expert.cancelFollow);

  apiV1Router.get('/expert/list.json', expert.getExpertList);
  apiV1Router.get('/expert/follow/list.json', tokenRequired, expert.getExpertFollowList);
  
  apiV1Router.get('/expert/detail.json', expert.getExpertDetail);
  apiV1Router.get('/expert/followDetail.json', tokenRequired, expert.getExpertFollowDetail);
  apiV1Router.get('/expert/lightDetail.json', expert.getLightExpertDetail);
  apiV1Router.get('/expert/evaluate/morelist.json', expert.getMoreExpertEvaluateList);

  apiV1Router.get('/expert/collect/parentlist.json', expert.getExpertParentCollectList);
  apiV1Router.get('/expert/collect/list.json', expert.getExpertCollectList);
  apiV1Router.post('/expert/collect/create.json', expert.createExpertCollect);


  apiV1Router.post('/order/subscription/createOrder.json', tokenRequired, order.createSubscriptionOrder);
  apiV1Router.get('/order/subscription/list.json', tokenRequired, order.getSubscriptionOrderList);
  apiV1Router.get('/order/subscription/detail.json', tokenRequired, order.getSubscriptionOrderDetail);

  apiV1Router.get('/order/list.json', tokenRequired, order.getOrderList);
  apiV1Router.get('/order/detail.json', tokenRequired, order.getOrderDetail);
  apiV1Router.get('/order/latest/detail.json', tokenRequired, order.getOrderLatestDetail);
  apiV1Router.post('/order/payment/pay.json', tokenRequired, order.getPayment);
  apiV1Router.post('/order/payment/done.json', tokenRequired, order.getPayment);
};
